const { defineConfig } = require('@vue/cli-service')
const path = require('path')

module.exports = defineConfig({
  transpileDependencies: true,
  configureWebpack: {
    resolve: {
      // 配置自动补充后缀名
      extensions: [".js", ".vue", ".json"],
      // 配置别名
      alias: {
        vue$: "vue/dist/vue.esm.js",
        "@": path.join(__dirname, "/src"),
        "~": path.join(__dirname, "/src/views"),
      },
    },
  },
  devServer: {
    proxy: {
      "/api": {
        //  /api表示拦截以/api开头的请求路径
        target: "http://localhost:9999/warehouse", // 后台地址
        changeOrigin: true, //是否开启跨域
        secure: false,
        pathRewrite: {
          // 重写路径
          "^/api": "", // 把/api变为空字符
        },
      },
    },
  },
});
